import React, {Component} from 'react';
import './index.css'

class Parent extends Component {
    render() {
        return (
            <div className="parent">
                <h3>Parent</h3>
                {/*<A/>*/}
                <A render={(name)=><B name={name}/>}/>
            </div>
        );
    }
}

class A extends Component {
    state = {name:'Tom'}
    render() {
        const {name} = this.state
        return (
            <div className="a">
              <h3>Achild</h3>
                {this.props.render(name)}
                {/*<B/>*/}
            </div>
        );
    }
}
class B extends Component {
    render() {
        return (
            <div className="b">
                <h3>B zujian</h3>
                <h4>姓名：{this.props.name}</h4>
            </div>
        );
    }
}

export default Parent;
